//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

using System;
using System.Collections.ObjectModel;
using Microsoft.Research.ScientificWorkflow.ManagementStudioModels;
using SR = Microsoft.Research.DataLayer;
using System.Security.Permissions;
using System.Collections.Generic;
using Microsoft.Research.ScientificWorkflow.TridentUtilities;

namespace ManagementStudioServices.Interfaces
{
    public interface IRegistryManagerService
    {
        SR.Namespace GetActivityCategories();

        SR.Namespace GetWorkflowCategories();

        bool DeleteWorkflowCategory(CategoryViewModel modelToDelete, CategoryViewModel moveToModel);

        SR.Namespace SaveCategory(CategoryViewModel model);

        SR.Machine SaveNode(NodeViewModel nodeModel);

        void DeleteNode(Guid nodeId);

        Collection<SR.Machine> GetNodes();

        SR.Machine GetNode(Guid nodeId);

        Collection<WorkflowViewModel> FetchCategoryActivitys(CategoryViewModel categoryViewModel);

        SR.Activity SaveActivity(ActivityViewModel model);

        bool ImportActivity(Collection<FileReference> references);

        Collection<WorkflowViewModel> FetchRelatedWorkflows(ActivityViewModel activityModel);

        SR.Activity SaveWorkflow(WorkflowCatalogViewModel model);

        bool DeleteWorkflow(WorkflowCatalogViewModel model);

        IEnumerable<SR.TypeInitializer> GetTypeInitializers();

        OperationStatus ImportTypeInitializer(string dllPath);

        void DeleteActivity(ActivityViewModel model);

        bool DeleteTypeInitializer(TypeInitializerModel model);

        SR.TypeInitializer SaveTypeInitializer(TypeInitializerModel typeInitializerModel);

        [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
        void OpenComposerForNewWorkflow();

        SR.Connection RegistryConnection
        {
            get;
        }

        string UserName
        {
            get;
        }

        Collection<WorkflowViewModel> FetchRelatedWorkflows(TypeInitializerModel typeInitializerModel);

        void DeletePackage(Guid delPackage);

        Collection<AssemblyPackageViewModel> GetAllAssemblyPackages();

        Collection<SR.User> GetAllUsers();

        bool SaveUser(UserViewModel model, out SR.User user);

        void DeleteUser(Guid ownerId, Guid userId);

        Collection<SR.Group> GetAllGroups();

        Collection<SR.Group> GetAllActiveGroups();

        bool SaveGroup(GroupViewModel model, out SR.Group group);

        void DeleteGroup(Guid groupId);

        ObservableCollection<SearchUserModel> GetAllActiveUsers();

        Collection<SR.User> GetAllUserByFilter(Guid userId);

        Collection<SR.Group> GetAllGroupByFilter(string userName);

        /// <summary>
        /// Gets all data reference providers.
        /// </summary>
        /// <returns></returns>
        Collection<DataReferenceProviderModel> GetAllDataReferenceProviders();

        /// <summary>
        /// Saves the data reference provider.
        /// </summary>
        /// <param name="providerModel">The provider model.</param>
        /// <returns></returns>
        SR.DataReferenceProvider SaveDataReferenceProvider(DataReferenceProviderModel providerModel);

        /// <summary>
        /// Imports the data reference provider.
        /// </summary>
        /// <param name="assemblyPath">The assembly path.</param>
        /// <returns></returns>
        bool? ImportDataReferenceProvider(string assemblyPath);

        /// <summary>
        /// Saves the data reference store.
        /// </summary>
        /// <param name="storeModel">The store model.</param>
        /// <returns></returns>
        SR.DataReferenceStore SaveDataReferenceStore(DataReferenceStoreModel storeModel);

        /// <summary>
        /// Deletes the data reference store.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        bool DeleteDataReferenceStore(DataReferenceStoreModel model);

        /// <summary>
        /// Deletes the data reference provider.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        bool DeleteDataReferenceProvider(DataReferenceProviderModel model);

        /// <summary>
        /// Fetches all enabled security principals.
        /// </summary>
        /// <returns></returns>
        IEnumerable<SR.ISecurityPrincipal> FetchAllEnabledSecurityPrincipals(bool includeEveryone);

        /// <summary>
        /// Gets all shared workflows.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        Collection<SR.Activity> GetAllSharedWorkflowsForCurrentUser();

        /// <summary>
        /// Gets the users my workflows.
        /// </summary>
        /// <param name="categories">The categories.</param>
        void GetMyWorkflowsForCurrentUser(Collection<SR.Namespace> categories);

        /// <summary>
        /// Gets all users my workflows.
        /// </summary>
        /// <param name="categories">The categories.</param>
        void GetAllUsersMyWorkflows(Collection<SR.Namespace> categories);

        /// <summary>
        /// Fetches the current user.
        /// </summary>
        /// <returns></returns>
        SR.User FetchCurrentUser();

        /// <summary>
        /// Get the system policies.
        /// </summary>
        /// <returns></returns>
        SR.SystemPolicy GetSystemPolicy();

        SR.GlobalSetting GetGlobalSetting();

        Collection<SR.DataReferenceStore> GetDataReferenceStores();

        void SaveGlobalSettings(string dataProduct);

        /// <summary>
        /// Load the assemblies and the input parameters into the model.
        /// </summary>
        /// <param name="workflowModel">The workflow model.</param>
        /// <param name="libraryList">The library list.</param>
        /// <param name="parameterList">The parameter list.</param>
        void GetWorkflowDetails(WorkflowCatalogViewModel workflowModel, Collection<WorkflowAssembly> libraryList, Collection<WorkflowParameter> parameterList);
    }
}
